
local mt = ac.skill['急速冲刺']
mt.title = '急速冲刺'
mt.art = [[ReplaceableTextures\CommandButtons\BTNAttackGround.blp]]
mt.is_order = 1
mt.targettype = '点'
mt.range = 99999
mt.smart_cast = 1
mt.cost = 40
mt.hotkey = 'D'
mt.tip = [[
主动：
朝鼠标放标冲刺]]

function mt:on_add()
    local hero = self.owner
    self:gc(hero:event '单位-禁用冲刺'(function()
        self:set_silent(true)
    end))
    self:gc(hero:event '单位-允许冲刺'(function()
        self:set_silent(false)
    end))
end

function mt:on_cast_shot()
    local hero = self.owner
    local player = hero.owner
    local point = self.target
    local angle = hero:get_point()/point
    local distance = math.min(hero:get_point()*point,800)
    local point = hero:get_point() - {angle,distance}
    if hero.jump_mover then
        hero.jump_mover:remove()
    end
    hero:add_restriction '硬直'
    hero.jump_mover = ac.mover('line')
    {
        mover = hero,
        angle = angle,
        speed = 2200,
        distance = distance,
        on_move = function(_,point)
            if point then
                point:effect
                {
                    model = hero:get_model(),
                    angle = angle,
                    hide_when_remove = true,
                    alpha = 50,
                    time = 0.2,
                }
            end
        end,
        on_remove = function()
            hero:remove_restriction '硬直'
            hero:issue_order('stop')
        end
    }
end


